package com.example.statistics.ui.yw

import android.os.Bundle
import com.example.statistics.R
import com.example.statistics.bean.yw.ProcessingBean
import com.example.statistics.common.BaseLoadingListActivity
import com.example.statistics.ex.goTimeFormat
import com.example.statistics.net.UrlConfig
import com.example.statistics.utils.Constants
import com.example.statistics.utils.activityForResult
import com.jhj.slimadapter.SlimAdapter
import com.jhj.slimadapter.holder.ViewInjector
import org.jetbrains.anko.startActivity

class PreProductProfitListActivity : BaseLoadingListActivity<ProcessingBean>() {

    override val title: String
        get() = "加工列表"

    override val url: String
        get() = UrlConfig.PROCESSING_LIST

    override val itemLayoutRes: Int
        get() = R.layout.list_item_common_display

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        topBarRightImage {
            activityForResult<MaterialToProductActivity>() {
                refresh()
            }
        }
    }

    override fun itemViewConvert(adapter: SlimAdapter, injector: ViewInjector, bean: ProcessingBean, position: Int) {
        injector.text(R.id.tv_title, "原料：${bean.materialWeight}KG | 成品${bean.productWeight}KG")
            .text(R.id.tv_subtitle, "预估利润：${bean.preProfit}")
            .text(R.id.tv_bottom_right, bean.date.goTimeFormat())
            .clicked {
                startActivity<PreProductProfitActivity>(Constants.ID to bean.ID)
            }
    }


}